﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ENG.EngStartQueueLib;

namespace ENG.EngStartQueue
{
  public partial class FrmOptions : Form
  {

    private ENG.EngStartQueueLib.Properties.Settings props
    {
      get
      {
        return Program.LibSett;
      }
    }

    public FrmOptions()
    {
      InitializeComponent();
    }

    private void FrmOptions_Load(object sender, EventArgs e)
    {
      System.Globalization.CultureInfo ci =
        System.Globalization.CultureInfo.CurrentCulture;
      btnSetToLang.Text =
        btnSetToLang.Text + " [" + ci.IetfLanguageTag + "]";
      btnSetToLang.Tag = ci;

      prg.SelectedObject = props;
    }

    private void btnOk_Click(object sender, EventArgs e)
    {
      props.Save();
    }

    private void btnCancel_Click(object sender, EventArgs e)
    {
      props.Reload();
    }

    private void btnCategories_Click(object sender, EventArgs e)
    {
      new FrmCategories().Show();
    }

    private void btnSetToLang_Click(object sender, EventArgs e)
    {
      Program.AdjustLocalization(true);
    }

    private void btnTestCategories_Click(object sender, EventArgs e)
    {
      PerformanceMeter pmd = null;
      PerformanceMeter pmp = null;

      try
      {
        Program.LoadPerformanceMeters(out pmd, out pmp);

        pmd.GetValue();
        pmp.GetValue();

        MessageBox.Show("Performance meters created correctly.", Application.ProductName,
          MessageBoxButtons.OK, MessageBoxIcon.Information);
      }
      catch (Exception ex)
      {
        MessageBox.Show(
          "Loading of performance meter failed. Reason: " + ex.Message,
          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
    }
  }
}
